-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Emit 'plotly_webglcontextlost' event on WebGL context lost #2986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- with event data containing the original event and the canvas 'key' to determine which canvas lost its context.
... before native 'webgl_contextlost' is triggered.
👍 for events in all cases.
Maybe not to cause a real context loss, but can we mock the native event, just so we can be sure the plotly event is triggered on any of the canvases losing their context? |
Good call. Done in -> 7e282c3 |
setTimeout(reject, 10); | ||
|
||
var ev = new window.WebGLContextEvent('webglcontextlost'); | ||
var canvas = gd.querySelector('.gl-canvas-context'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant by "triggered on any of the canvases losing their context" is, for this one plot we make 3 canvases, each with its own webgl context... any of them could in principle lose its context, right?
> gd.querySelectorAll('canvas')
NodeList(3) [
canvas.gl-canvas.gl-canvas-context,
canvas.gl-canvas.gl-canvas-focus,
canvas.gl-canvas.gl-canvas-pick
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you caught me being lazy.
Better tests in 905956a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even better tests in 3a38d73
- test gl2d 'focus' canvas - test the 3 parcoords canvases!
💃 |
will be in plotly/documentation#1085 |
cc @alexcjohnson
I'm not sure if there's a way to actually test this.
This PR makes regl-based graphs emit an event on WebGL context lost from one of our canvases.
Note that gl3 already sort of does this:
plotly.js/src/plots/gl3d/scene.js
Lines 231 to 234 in ff3c324
but logs something instead of emitting an event. Personally, I think emitting an event is better, but maybe consistency with gl3d is best (this is, before the v2 push).